package com.hamu.mapper;

import com.hamu.pojo.Article;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface ArticleMapper {
    //新增
    @Insert("insert into articles(title,content,media_url,state,category_id,create_user,create_time,update_time)"+
            "values(#{title},#{content},#{mediaUrl},#{state},#{categoryId},#{createUser},#{createTime},#{updateTime})")
    void add(Article article);

    List<Article> list(Integer userId, Integer categoryId, String state,List<String> tagNames,List<String> tagIds);

    List<Article> listAll(Integer categoryId, String state,List<String> tagNames,List<String> tagIds);

    //查找
    @Select("select * from articles where id=#{id}")
    Article findById(Integer id);
    //更新
    @Update("update articles set title=#{title},content=#{content},media_url=#{mediaUrl},state=#{state},category_id=#{categoryId},update_time=#{updateTime} where id=#{id}")
    void update(Article article);
    //删除
    @Delete("delete from articles where id=#{id}")
    void delete(Integer id);

    List<Article> searchArticles(Integer categoryId, String state, List<String> tagNames,List<String> tagIds, String query);
}
